export interface SideNav {
  title: string,
  count: string,
  isSelect: boolean,
  child?: SideNav[] // 子菜单
}

export function useSideNav() {
  let sideNavList: SideNav[] = [
    {
      title: 'Additives',
      count: '6k+',
      isSelect: false,
      child: [
        {
          title: 'Additive Free',
          count: '461',
          isSelect: false
        },
        {
          title: 'Filler Free',
          count: '54',
          isSelect: false
        },
        {
          title: 'No Artificial Colours',
          count: '6778',
          isSelect: false
        },
        {
          title: 'No Artificial Flavours',
          count: '6421',
          isSelect: false
        },
        {
          title: 'No Artificial Preservatives',
          count: '4914',
          isSelect: false
        },
        {
          title: 'No Artificial Sweeteners',
          count: '556',
          isSelect: false
        }
      ]
    },
    {
      title: 'Allergies & Intolerances',
      count: '10k+',
      isSelect: false,
      child: [
        {
          title: 'Dairy Free',
          count: '39',
          isSelect: false
        },
        {
          title: 'Egg Free',
          count: '39',
          isSelect: false
        },
        {
          title: 'Fish Free',
          count: '39',
          isSelect: false
        }
      ]
    },
    {
      title: 'Certifications',
      count: '3k+',
      isSelect: false,
      child: [
        {
          title: 'Certified Organic',
          count: '10',
          isSelect: false
        }
      ]
    },
    {
      title: 'Diet Preferences',
      count: '8k+',
      isSelect: false,
      child: [
        {
          title: 'Keto',
          count: '3',
          isSelect: false
        }
      ]
    },
    {
      title: 'Environmental/Sustainable',
      count: '600+',
      isSelect: false,
      child: [
        {
          title: 'BPA-Free Packaging',
          count: '5',
          isSelect: false
        }
      ]
    },
    {
      title: 'Locally Produced',
      count: '5k+',
      isSelect: false,
      child: [
        {
          title: 'Made in Australia',
          count: '7',
          isSelect: false
        }
      ]
    },
    {
      title: 'Medical Diets',
      count: '200',
      isSelect: false,
      child: [
        {
          title: 'Celiac / Coeliac',
          count: '2',
          isSelect: false
        }
      ]
    },
    {
      title: 'Nutrition/Marketing Claims',
      count: '1k+',
      isSelect: false,
      child: [
        {
          title: 'Alcohol Free',
          count: '4',
          isSelect: false
        }
      ]
    },
    {
      title: 'Religious Diets',
      count: '1k+',
      isSelect: false,
      child: [
        {
          title: 'Halal',
          count: '2',
          isSelect: false
        }
      ]
    },
  ]

  const openSideNavList = (item: SideNav) => {
    sideNavList = sideNavList.map(obj => {
      console.log(item, 1111)
      if (obj.title === item.title) {
        return { ...obj, isSelect: true }
      }
      return { ...obj }
    })
  };

  return {
    sideNavList,
    openSideNavList
  }
}